package com.itheima.controller;

import com.itheima.pojo.entity.PageResult;
import com.itheima.pojo.entity.Result;
import com.itheima.pojo.log.EmpLog;
import com.itheima.service.EmpLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zzw
 * @date 2025/4/29
 * @description 员工操作日志控制器
 */
@Slf4j
@RestController
@RequestMapping("/log")
public class EmpLogController {

    @Autowired
    private EmpLogService empLogService;

    /**
     * 日志分页查询
     *
     * @param page     页码
     * @param pageSize 每页条数
     * @return Result
     */
    @GetMapping("/page")
    public Result getLogPage(@RequestParam(defaultValue = "1") Integer page,
                             @RequestParam(defaultValue = "10") Integer pageSize) {
        PageResult<EmpLog> pageResult = empLogService.page(page, pageSize);
        return Result.success(pageResult);
    }
}
